﻿Public Class ListeTraitementsBase(Of T)
    Implements IDictionary(Of T, ITraitement)
    Implements IListeTraitements

    Public Sub New(ByVal Connection As IConnection,
                   ByVal DataSet As DataSet)
        m_Connection = Connection
        m_DataSet = DataSet
        m_ListeTraitements = New Dictionary(Of T, ITraitement)
    End Sub

#Region "Connection"
    Private m_Connection As IConnection
    Public ReadOnly Property Connection As IConnection Implements IListeTraitements.Connection
        Get
            Return m_Connection
        End Get
    End Property
#End Region

#Region "DataSet"
    Private m_DataSet As DataSet
    Public ReadOnly Property DataSet As DataSet Implements IListeTraitements.DataSet
        Get
            Return m_DataSet
        End Get
    End Property
#End Region

#Region "IDictionary (Of T, ITraitement)"
    Private m_ListeTraitements As IDictionary(Of T, ITraitement)
    Public Sub AddKeyValuePair(ByVal item As System.Collections.Generic.KeyValuePair(Of T, ITraitement)) Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).Add
        item.Value.DataSet = m_DataSet
        item.Value.Connection = m_Connection.Connection
        m_ListeTraitements.Add(item)
    End Sub
    Public Sub Clear() Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).Clear
        m_ListeTraitements.Clear()
    End Sub
    Public Function Contains(ByVal item As System.Collections.Generic.KeyValuePair(Of T, ITraitement)) As Boolean Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).Contains
        Return m_ListeTraitements.Contains(item)
    End Function
    Public Sub CopyTo(ByVal array() As System.Collections.Generic.KeyValuePair(Of T, ITraitement), ByVal arrayIndex As Integer) Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).CopyTo
        m_ListeTraitements.CopyTo(array, arrayIndex)
    End Sub
    Public ReadOnly Property Count As Integer Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).Count
        Get
            Return m_ListeTraitements.Count
        End Get
    End Property
    Public ReadOnly Property IsReadOnly As Boolean Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).IsReadOnly
        Get
            Return m_ListeTraitements.IsReadOnly
        End Get
    End Property
    Public Function RemoveKeyValuePair(ByVal item As System.Collections.Generic.KeyValuePair(Of T, ITraitement)) As Boolean Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).Remove
        Return m_ListeTraitements.Remove(item)
    End Function
    Public Sub Add(ByVal key As T, ByVal value As ITraitement) Implements System.Collections.Generic.IDictionary(Of T, ITraitement).Add
        value.DataSet = m_DataSet
        value.Connection = m_Connection.Connection
        m_ListeTraitements.Add(key, value)
    End Sub
    Public Function ContainsKey(ByVal key As T) As Boolean Implements System.Collections.Generic.IDictionary(Of T, ITraitement).ContainsKey
        Return m_ListeTraitements.ContainsKey(key)
    End Function
    Default Public Property Item(ByVal key As T) As ITraitement Implements System.Collections.Generic.IDictionary(Of T, ITraitement).Item
        Get
            Return m_ListeTraitements.Item(key)
        End Get
        Set(ByVal value As ITraitement)
            m_ListeTraitements.Item(key) = value
        End Set
    End Property
    Public ReadOnly Property Keys As System.Collections.Generic.ICollection(Of T) Implements System.Collections.Generic.IDictionary(Of T, ITraitement).Keys
        Get
            Return m_ListeTraitements.Keys
        End Get
    End Property
    Public Function Remove(ByVal key As T) As Boolean Implements System.Collections.Generic.IDictionary(Of T, ITraitement).Remove
        Return m_ListeTraitements.Remove(key)
    End Function
    Public Function TryGetValue(ByVal key As T, ByRef value As ITraitement) As Boolean Implements System.Collections.Generic.IDictionary(Of T, ITraitement).TryGetValue
        Return m_ListeTraitements.TryGetValue(key, value)
    End Function
    Public ReadOnly Property Values As System.Collections.Generic.ICollection(Of ITraitement) Implements System.Collections.Generic.IDictionary(Of T, ITraitement).Values
        Get
            Return m_ListeTraitements.Values
        End Get
    End Property
    Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)) Implements System.Collections.Generic.IEnumerable(Of System.Collections.Generic.KeyValuePair(Of T, ITraitement)).GetEnumerator
        Return m_ListeTraitements.GetEnumerator
    End Function
    Public Function GetEnumeratorIEnumerable() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
        Return m_ListeTraitements.GetEnumerator
    End Function
#End Region

End Class
